<?php

namespace pmvc\template;

use pmvc\io\Stream;

class SmartyTemplate
	implements Template {

	private $smarty 	= NULL;
	private $template	= NULL;

	public function __construct(&$smarty, $template) {
		$this->smarty 	= $smarty;
		$this->template	= $template;
	}

	public function addFunction($name, $functionName) {
		$this->smarty->register_function($name, $functionName);
	}

	public function addVariable($name, $value) {
		$this->smarty->assign($name, $value);
	}

	public function addVariables($vars) {
		$this->smarty->assign($vars);
	}

	public function renderAsString() {
		return $this->smarty->fetch($this->template);
	}

	public function render(Stream $stream) {
		$stream->write($this->renderAsString());
	}

}

?>